'use strict'
angular.module('core').run(['$rootScope', '$state','Authentication', function($rootScope, $state,Authentication) {
  $rootScope.$on('$stateChangeStart', function (event, toState) {
    if(toState.authenticate){
      if(!Authentication.isAuthenticated){
        //$location.url('home');
        event.preventDefault();
        $state.go('home');
      }
    }
    else{
      if(Authentication.isAuthenticated){
        event.preventDefault();
        $state.go('dashboardMain');
      }
    }
  });
}]);
